package com.company.huisuo.biz.fragment

import androidx.recyclerview.widget.GridLayoutManager
import com.company.huisuo.R
import com.company.huisuo.base.BaseFragment
import com.company.huisuo.biz.activity.ArtistInfoActivity
import com.company.huisuo.biz.adapter.ArtistShowListAdapter
import com.company.huisuo.biz.bean.ArtistBean
import com.company.huisuo.databinding.FragmentArtistShowBinding

/**
 * 艺人选秀列表
 */
class ArtistShowListFragment : BaseFragment<FragmentArtistShowBinding>() {

    private val mAdapter by lazy {
        ArtistShowListAdapter()
    }

    companion object {
        fun newInstance(): ArtistShowListFragment {
            return ArtistShowListFragment()
        }
    }

    override fun initView() {
        mBinding?.rcvList?.apply {
            layoutManager = GridLayoutManager(activity, 2)
            adapter = mAdapter
        }

        mAdapter.addOnItemChildClickListener(R.id.tv_select) { adapter, view, position ->
            if (position <= 1) {
                //我就选她
                ArtistInfoActivity.start(requireActivity(), mAdapter.getItem(position))
            } else {
                //艺人试台

            }
        }
    }

    override fun initData() {
        mAdapter.submitList(ArtistBean.LIST)
    }
}